package com.itheima.mapper;

import com.itheima.pojo.PetAdoptionInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PetAdoptionInfoMapper {
    //新增
    @Insert("insert into pet_adoption_info(img,species,sex,age,type,descr,sterilization,health,adoption) " +
            "values(#{img},#{species},#{sex},#{age},#{type},#{descr},#{sterilization},#{health},#{adoption})")
    void add(PetAdoptionInfo petAdoptionInfo);

    //查询所有
    List<PetAdoptionInfo> list(String type,String species);

    //根据id查询
    @Select("select * from pet_adoption_info where id = #{id}")
    PetAdoptionInfo findById(Integer id);

    //更新
    @Update("update pet_adoption_info set species=#{species},type=#{type},sex=#{sex},img=#{img},sterilization=#{sterilization},health=#{health},descr=#{descr},status=#{status},age=#{age} where id=#{id}")
    void update(PetAdoptionInfo petAdoptionInfo);

    @Update("update pet_adoption_info set status=#{status} where id=#{id}")
    void updateStatus(Integer id,String status);

    //删除
    @Delete("delete from pet_adoption_info where id = #{id}")
    void delete(PetAdoptionInfo petAdoptionInfo);
}
